/*
 * @Description: router from vue
 * @Author: your name
 * @Date: 2019-10-17 10:05:12
 * @LastEditTime: 2019-10-17 11:35:22
 * @LastEditors: Please set LastEditors
 */
import Vue from 'vue'
import Router from 'vue-router'
import Header from './components/Header.vue'
import Asy from './components/Asy.vue'

Vue.use(Router)

const router = new Router({
    mode: 'history',
    base: process.env.BASE_URL,
    routes: [{
            path: '/',
            redirect: '/index'
        },
        {
            path: '/index',
            component() {
                return import('./components/HelloWorld.vue')
            }
        },
        {
            path: '/header',
            component: Header,
            name: 'header',
            children: [
                {path:'',component:Header},
                {path: 'asy/:age',component:Asy},
            ]
        },
        {
            path: '*',
            redirect: '/index'
        }
    ]
})

// 路由守卫

router.beforeEach((to, from, next) => {
    // do something   
    next()
})

export default router